package me.shan.hanoi;

/**
 * 汉诺塔递归版
 *
 * @author liuchuang
 * @version 1.0
 * @since 2023/5/26 16:50
 */
public class HanoiR {

    public static void hanoi(int n, char from, char via, char to) {
        if (n == 1) {
            System.out.printf("%c -> %c\n", from, to);
        } else {
            hanoi(n - 1, from, to, via);
            hanoi(1, from, via, to);
            hanoi(n - 1, via, from, to);
        }
    }

    public static void main(String[] args) {
        hanoi(3, 'A', 'B', 'C');
    }

}
